package com.situ.company.project.service.impl;

import java.util.List;

import com.situ.company.employee.model.EmployeeModel;
import com.situ.company.project.dao.IProjectDao;
import com.situ.company.project.dao.impl.ProjectDaoImpl;
import com.situ.company.project.model.ProjectModel;
import com.situ.company.project.service.IProjectService;
import com.situ.company.util.MD5;

public class ProjectServiceImpl implements IProjectService{

	private IProjectDao dao = new ProjectDaoImpl();
	@Override
	public String insert(ProjectModel model) {
		ProjectModel m1 = new ProjectModel();
		m1.setCode(model.getCode());
		ProjectModel mdb = dao.selectModel(m1);
		if(mdb!=null)
			return "repeat";
		return dao.insert(model)+"";
		
	}

	@Override
	public String delete(ProjectModel model) {
		return dao.deleteByCode(model)+"";
	}

	@Override
	public String update(ProjectModel model) {
		return dao.updateActive(model)+"";
	}

	@Override
	public List<ProjectModel> selectList(ProjectModel model) {
		String code = model.getCode();
		model.setCode(code==null?"%":"%"+code+"%");
		String name = model.getName();
		model.setName(name==null?"%":"%"+name+"%");
		return dao.selectList(model);
	}

	@Override
	public ProjectModel selectModel(ProjectModel model) {
		return dao.selectModel(model);
	}

	@Override
	public Integer selectCount(ProjectModel model) {
		ProjectModel m1 = new ProjectModel();
		String code = model.getCode();
		m1.setCode(code==null?"%":"%"+code+"%");
		String name = model.getName();
		m1.setName(name==null?"%":"%"+name+"%");
		return dao.selectCount(m1);
	}

}
